<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录</title>
        <!-- CSS -->
        <link rel="stylesheet" href="__STATIC__/assets/css/reset.css">
        <link rel="stylesheet" href="__STATIC__/assets/css/supersized.css">
        <link rel="stylesheet" href="__STATIC__/assets/css/style.css">
        <link rel="stylesheet" type="text/css" href="__CSS__/login.css">
        <style>
        	p.err{display: none;color: #f00;font-size: 18px;padding: 5px 0px;}
        	.layui-layer-content{color: #333;}
        </style>
</head>
<body>
        <div class="page-container">	           
			<div class="wrapper">	
				<div class="container">
					<strong><span style="font-weight: bold;font-size: 25px;">Login</span></strong> 
					<form class="form" action="" method="post" id="form-login">
						<input type="text"     name="name"      id="username" placeholder="Username">
						<input type="password" name="password"  id="password" placeholder="Password">
						<p class="err"></p>
						<button type="button" id="login-button">登  录</button>
					</form>
				</div>
		    </div>
        </div>
	
		<script type="text/javascript">
			// 定义路径
			var dir = '<?php echo "__IMG__";?>';


		</script>
        <!-- Javascript -->
        <script src="__JS__/jquery-2.1.1.min.js"></script>
        <script src="__JS__/supersized.3.2.7.min.js"></script>
        <script src="__JS__/supersized-init.js"></script>
        <script src="__JS__/scripts.js"></script>
		<script type="text/javascript" src="__STATIC__/layui/layui.js"></script>
		<script type="text/javascript">

			layui.use(['form','layer'],function(){
				var form  = layui.form,
					layer = layui.layer,
					$ = layui.$;

	            // 按键绑定
	            $(document).keyup(function(event){
	                if(event.keyCode ==13){
                        $("#login-button").trigger("click");
	                }
	            });

			 	// 提交数据
				$("#login-button").click(function(){
			 		var index = top.layer.msg('登录中...',{icon: 16,time:false});

					var name = $("#username").val();
					var pass = $("#password").val();
					var form_data = $("#form-login").serialize();
					if (!name) {
		        		layer.msg("Please Enter Username", {icon: 2, offset: '30%'});
		        		$("#username").focus();
		        		return;
					}
					if (!pass) {
		        		layer.msg("Please Enter Password", {icon: 2, offset: '30%'});
		        		$("#password").focus();
		        		return;
					}
					$.ajax({
						type: "POST",
				        url:"/admin/login/enter_web",
						data:form_data,
						dataType:'json',
				        success: function(data){
			            	top.layer.close(index);
				        	
				        	if(data.status == -1){
				        		$("p.err").text(data.msg);
				        		$("p.err").show();
				        	}else{
				        		layer.msg(data.msg, {icon: 1, offset: '30%'}, function(){
				        			window.location.href = "/admin/index/index";
				        		});
				        	}
				        }
					})
				})
				
			})

		</script>
</body>
</html>